package com.eve.springcloud.common;

import java.util.HashMap;
import java.util.Map;

/**
 * 
* @ClassName: Jsons 
* @Description: 返回的数据
*
 */ 
public class Jsons extends HashMap<Object,Object> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 没登录 code  501
	 */
	public  static final int NO_LOGIN_CODE = 501;

	public Jsons() {
		put("code", 0);
	}
	
	public static Jsons error() {
		Jsons r = new Jsons();
		r.put("code", 500);
		return  r;
	}
	
	public static Jsons error(String msg) {
//		msg = MessageUtils.getMessage(msg, null);
		return error(500, msg);
	}
	
	public static Jsons error(int code, String errors) {
		Jsons r = new Jsons();
		r.put("code", code);
//		errors = MessageUtils.getMessage(errors, null);
		r.put("msg", errors);
		return r;
	}

	public static Jsons ok(String msg) {
		Jsons r = new Jsons();
//		msg = MessageUtils.getMessage(msg, null);
		r.put("msg", msg);	
		
		return r;
	}
	
	public static Jsons ok(Map<String, Object> map) {
		Jsons r = new Jsons();
		r.putAll(map);
		return r;
	}
	
	public static Jsons ok() {
		return new Jsons();
	}

	public Jsons put(String key, Object value) {
		super.put(key, value);
		return this;
	}
	
}
